package com.zxy.furns.dao.impl;

import com.zxy.furns.dao.BasicDAO;
import com.zxy.furns.dao.OrderItemDAO;
import com.zxy.furns.entity.OrderItem;

import javax.print.DocFlavor;
import java.util.List;

/**
 * ClassName: OrderItemImpl
 * Package: com.zxy.furns.dao.impl
 *
 * @Author zxy
 * @Create 2025/3/25 23:22
 * @Version 1.0
 * title:
 * Description:
 */
public class OrderItemImpl extends BasicDAO<OrderItem> implements OrderItemDAO {
    @Override
    public int saveOrderItem(OrderItem orderItem) {
        String sql = "INSERT INTO `order_item`(id,name,price,count,total_price,order_id) VALUES(?,?,?,?,?,?)";
        return update(sql, orderItem.getId(), orderItem.getName(), orderItem.getPrice(), orderItem.getCount(), orderItem.getTotalPrice(), orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> listOrderItem(String orderId) {
        String sql = "SELECT id,name,price,count,total_price totalPrice  FROM `order_item` WHERE order_id=?";
        return queryMulti(sql,OrderItem.class,orderId);
    }
}
